<?php

require_once 'Checker.php';
require_once 'InputValidator.php';

class TextValidator implements InputValidator{

    private $minLength;
    private $maxLength;

    public function __construct($minLength = 0, $maxLength = null){
        $this->minLength = $minLength;
        $this->maxLength = $maxLength;
    }

    public function validate($input){
        if($input === null)return false;
        $length = strlen($input);
        if($length < $this->minLength)return false;
        if($this->maxLength != null && $length > $this->maxLength)return false;
        return true;
    }

}
?>
